<?php

namespace app\models\db;

use Yii;

/**
 * This is the model class for table "t_e_shop".
 *
 * @property string $id
 * @property string $mini_programs_id
 * @property string $name
 * @property string $logo_url
 * @property string $brief_introduction
 * @property integer $is_on
 * @property string $cert_url
 * @property string $key_url
 * @property string $root_url
 * @property integer $is_main
 * @property string $create_datetime
 * @property integer $sort
 * @property string $begin_datetime
 * @property string $end_datetime
 * @property string $contact_man
 * @property string $contact_phone
 * @property integer $status
 * @property double $lan
 * @property double $lat
 *
 * @property MiniPrograms $miniPrograms
 */
class EShop extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 't_e_shop';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id'], 'required'],
            [['is_on', 'is_main', 'sort', 'status'], 'integer'],
            [['create_datetime', 'begin_datetime', 'end_datetime'], 'safe'],
            [['lan', 'lat'], 'number'],
            [['id', 'mini_programs_id'], 'string', 'max' => 36],
            [['name', 'logo_url', 'brief_introduction', 'cert_url', 'key_url', 'root_url'], 'string', 'max' => 255],
            [['contact_man', 'contact_phone'], 'string', 'max' => 20],
            [['mini_programs_id'], 'exist', 'skipOnError' => true, 'targetClass' => MiniPrograms::className(), 'targetAttribute' => ['mini_programs_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'mini_programs_id' => 'Mini Programs ID',
            'name' => 'Name',
            'logo_url' => 'Logo Url',
            'brief_introduction' => 'Brief Introduction',
            'is_on' => 'Is On',
            'cert_url' => 'Cert Url',
            'key_url' => 'Key Url',
            'root_url' => 'Root Url',
            'is_main' => 'Is Main',
            'create_datetime' => 'Create Datetime',
            'sort' => 'Sort',
            'begin_datetime' => 'Begin Datetime',
            'end_datetime' => 'End Datetime',
            'contact_man' => 'Contact Man',
            'contact_phone' => 'Contact Phone',
            'status' => 'Status',
            'lan' => 'Lan',
            'lat' => 'Lat',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getMiniPrograms()
    {
        return $this->hasOne(MiniPrograms::className(), ['id' => 'mini_programs_id']);
    }
}
